package com.neteast.androidclient.newscenter.domain;

import java.nio.ByteBuffer;

public class LoginResponse {
	/** 通信协议*/
	public int protocolVersion;
	/** 报文id*/
	public int msgId;
	/** 心跳间隔*/
	public int keepaliveTime;
	/** 保留字段长度*/
	public int reserveLen;
	/** 保留数据*/
	public byte[] reserve;
	
	private ByteBuffer byteBuffer;
	
	public LoginResponse(ByteBuffer byteBuffer) {
		this.byteBuffer=byteBuffer;
		init();
	}
	
	private void init() {
		protocolVersion=byteBuffer.getInt();
		msgId=byteBuffer.getInt();
		keepaliveTime=byteBuffer.getInt();
		reserveLen=byteBuffer.getInt();
		if (reserveLen>0) {
			reserve=new byte[reserveLen];
			for (int i = 0; i <reserveLen; i++) {
				reserve[i]=byteBuffer.get();
			}
		}
	}

	@Override
	public String toString() {
		return "LoginResponse [protocolVersion=" + protocolVersion + ", msgId="
				+ msgId + ", keepaliveTime=" + keepaliveTime + ", reserveLen="
				+ reserveLen + "]";
	}
}
